<template>
  <div>
    <van-nav-bar :title="comment.reply_count ?comment.reply_count+'条回复' : '暂无回复' ">
      <template #left>
        <van-icon @click="$emit('repClose')" name="cross" />
      </template>
    </van-nav-bar>

    <div class="scroll-wrap">
      <!-- 当前评论回复信息 -->
      <CommentItem :item="comment" />

      <!-- 全部回复评论 -->
      <van-cell title="全部回复" />
      <AcrticleComment type="c" :source="comment.com_id" :list="list" />

    </div>
    <!-- 底部发布区域 -->
    <div class="post-warp">
      <van-button round @click="isShowreply=true">评论</van-button>
    </div>
    <!-- 评论弹出层 -->
    <van-popup v-model="isShowreply" position="bottom">
      <acrticlePost @onpostSuccuss="inPostClick" :target="comment.com_id" :artId="$route.params.art_id" />
    </van-popup>
  </div>
</template>

<script>
import CommentItem from '@/components/comment-item/index.vue'
import AcrticleComment from './articleComment.vue'
import acrticlePost from './article-post.vue'
export default {
  name: 'replyPost',
  props: {
    // 从父组件传过来的数据信息
    comment: {
      type: Object,
      required: true
    }
  },
  data () {
    return {
      list: [],
      isShowreply: false
    }
  },
  methods: {
    inPostClick (e) {
      this.list.unshift(e)
      this.isShowreply = false
      this.comment.reply_count++
    }
  },
  computed: {},
  watch: {},
  filters: {},
  components: {
    CommentItem,
    AcrticleComment,
    acrticlePost
  },
  created () {
    // console.log(this.comment)
  },
  mounted () { }
}
</script>

<style scoped lang='less'>
.scroll-wrap {
  position: fixed;
  top: 92px;
  bottom: 102px;
  width: 100%;
  overflow-y: scroll;
}
.post-warp {
  width: 100%;
  height: 100px;
  position: fixed;
  bottom: 0;
  border-top: 1px solid #ccc;
  display: flex;
  align-items: center;
  justify-content: center;
  .van-button {
    width: 640px;
    height: 80px;
  }
}
</style>
